import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;
import java.util.Scanner;

public class Attack_Defence_TacticalCollide {
    static int FirstFive = 10;
    static int FirstAsh = 120;
    static boolean FirstFiveYes = false;
    static boolean FirstAshYes = false;
    static boolean FirstOtherFiveYes = false;
    static ArrayList<String> SixStarOperator = new ArrayList<>();
    static ArrayList<String> FiveStarOperator = new ArrayList<>();
    static ArrayList<String> FourStarOperator = new ArrayList<>();
    static ArrayList<String> ThreeStarOperator = new ArrayList<>();

    public static void SixStar() {
        String[] Operator = {
                "能天使",//0
                "推进之王",//1
                "伊芙利特",//2
                "艾雅法拉",//3
                "安洁莉娜",//4
                "闪灵",//5
                "夜莺",//6
                "星熊",//7
                "塞雷娅",//8
                "银灰",//9
                "斯卡蒂",//10
                "陈",//11
                "黑",//12
                "赫拉格",//13
                "麦哲伦",//14
                "莫斯提马",//15
                "煌",//16
                "阿",//17
                "刻俄柏",//18
                "风笛",//19
                "傀影",//20
                "温蒂",//21
                "早露",//22
                "铃兰",//23
                "棘刺",//24
                "森蚺",//25
                "史尔特尔",//26
                "瑕光",//27
                "泥岩",//28
                "山",//29
                "空弦",//30
                "嵯峨",//31
        };
        String[] LimitRainbowSixOperator = {
                "灰烬",//0
        };
        Random i = new Random();
        String GetOperator;
        System.out.print("\033[31m");
        int m = i.nextInt(10);
        if (m < 3) {//非UP
            int n = i.nextInt(Operator.length);
            GetOperator = Operator[n];
        }
        else GetOperator = LimitRainbowSixOperator[0];//UP

        if (FirstAsh == 1 && !GetOperator.equals(LimitRainbowSixOperator[0])) GetOperator = LimitRainbowSixOperator[0];//第120抽必为灰烬
        if (GetOperator.equals(LimitRainbowSixOperator[0])) FirstAshYes = true;
        System.out.println(GetOperator);
        SixStarOperator.add(GetOperator);
    }

    public static void FiveStar() {
        String[] Operator = {
                "白面鸮",//0
                "凛冬",//1
                "德克萨斯",//2
                "芙兰卡",//3
                "拉普兰德",//4
                "幽灵鲨",//5
                "蓝毒",//6
                "白金",//7
                "陨星",//8
                "天火",//9
                "梅尔",//10
                "赫默",//11
                "华法琳",//12
                "临光",//13
                "红",//14
                "雷蛇",//15
                "可颂",//16
                "普罗旺斯",//17
                "守林人",//18
                "崖心",//19
                "初雪",//20
                "真理",//21
                "空",//22
                "狮蝎",//23
                "食铁兽",//24
                "夜魔",//25
                "诗怀雅",//26
                "格劳克斯",//27
                "星极",//28
                "送葬人",//29
                "槐琥",//30
                "苇草",//31
                "布洛卡",//32
                "灰喉",//33
                "吽",//34
                "惊蛰",//35
                "慑砂",//36
                "巫恋",//37
                "极境",//38
                "石棉",//39
                "月禾",//40
                "莱恩哈特",//41
                "断崖",//42
                "蜜蜡",//43
                "贾维",//44
                "安哲拉",//45
                "燧石",//46
                "四月",//47
                "奥斯塔",//48
                "絮雨",//49
                "卡夫卡",//50
                "爱丽丝",//51
                "乌有",//52
        };
        String[] LimitRainbowSixOperator = {
                "霜华",//0
                "闪击",//1
        };
        Random i = new Random();
        String GetOperator;
        System.out.print("\033[33m");
        int m = i.nextInt(2);
        if (m < 1) {
            int n = i.nextInt(Operator.length);
            GetOperator = Operator[n];
        }
        else {
            int n = i.nextInt(LimitRainbowSixOperator.length);
            GetOperator = LimitRainbowSixOperator[n];
        }

        if (!FirstOtherFiveYes && FiveStarOperator.size() != 0) {//另一个五星UP
            if (FiveStarOperator.get(FiveStarOperator.size() - 1).equals(LimitRainbowSixOperator[0])) {
                GetOperator = LimitRainbowSixOperator[1];
                FirstOtherFiveYes = true;
            }
            if (FiveStarOperator.get(FiveStarOperator.size() - 1).equals(LimitRainbowSixOperator[1])) {
                GetOperator = LimitRainbowSixOperator[0];
                FirstOtherFiveYes = true;
            }
        }

        System.out.println(GetOperator);
        FiveStarOperator.add(GetOperator);
    }

    public static void FourStar() {
        String[] Operator = {
                "夜烟",//0
                "远山",//1
                "杰西卡",//2
                "流星",//3
                "白雪",//4
                "清道夫",//5
                "红豆",//6
                "杜宾",//7
                "缠丸",//8
                "霜叶",//9
                "慕斯",//10
                "砾",//11
                "暗索",//12
                "末药",//13
                "调香师",//14
                "角峰",//15
                "蛇屠箱",//16
                "古米",//17
                "深海色",//18
                "地灵",//19
                "阿消",//20
                "猎蜂",//21
                "格雷伊",//22
                "苏苏洛",//23
                "桃金娘",//24
                "红云",//25
                "梅",//26
                "安比尔",//27
                "宴",//28
                "刻刀",//29
                "波登可",//30
                "卡达",//31
                "孑",//32
                "酸糖",//33
                "芳汀",//34
                "泡泡",//35
                "杰克",//36
                "松果",//37
                "豆苗",//38
        };
        Random i = new Random();//定义随机
        String GetOperator;
        /*int[] Up = {};*/
        System.out.print("\033[35m");//设置字体颜色
        int n = i.nextInt(Operator.length);//随机n
        GetOperator = Operator[n];//输出干员
        System.out.println(GetOperator);
        FourStarOperator.add(GetOperator);
    }

    public static void ThreeStar() {
        String[] Operator = {
                "芬",//0
                "香草",//1
                "翎羽",//2
                "玫兰莎",//3
                "卡缇",//4
                "米格鲁",//5
                "克洛丝",//6
                "炎熔",//7
                "芙蓉",//8
                "安赛尔",//9
                "史都华德",//10
                "梓兰",//11
                "空爆",//12
                "月见夜",//13
                "斑点",//14
                "泡普卡",//15
        };
        Random i = new Random();
        String GetOperator;
        /*int[] Up = {};*/
        System.out.print("\033[37m");
        int n = i.nextInt(Operator.length);
        GetOperator = Operator[n];
        System.out.println(GetOperator);
        ThreeStarOperator.add(GetOperator);
    }

    public static int Headhunt(int k) {
        Random i = new Random();
        int l = k, S1 = 97, S2 = 89, S3 = 39;
        int n = i.nextInt(100);
        l ++;
        if (l > 50) {
            S1 = 97 - (l - 50) * 2;
            S2 = 89 - (l - 50) * 2 + (l - 50) / 8;
            S3 = 39 - (l - 50) + (l - 50) / 8;
        }
        if (FirstFive == 1 && n <= S2) {//五星保底只剩一次且下一次不是五星以上
            int j = i.nextInt(10);
            if (j < 2) SixStar();
            else FiveStar();
            FirstFiveYes = true;
        }
        else {
            if (n > S1) {SixStar(); FirstFiveYes = true;}
            else if (n > S2) {FiveStar(); FirstFiveYes = true;}
            else if (n > S3) FourStar();
            else ThreeStar();
        }
        if (!FirstAshYes) FirstAsh--;
        else FirstAsh = 0;
        if (!FirstFiveYes) FirstFive--;
        else FirstFive = 0;
        if (n > S1) l = 0;//抽到六星，未抽到六星次数归零
        return l;
    }

    public static void History() {
        ArrayList<String> AllGetOperator = new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            switch (i) {
                case 0: {
                    AllGetOperator = (ArrayList<String>) SixStarOperator.clone();
                    if (AllGetOperator.size() != 0){
                        System.out.print("\033[31m");
                        System.out.println("★★★★★★:");
                    }
                    break;
                }
                case 1: {
                    AllGetOperator = (ArrayList<String>) FiveStarOperator.clone();
                    if (AllGetOperator.size() != 0){
                        System.out.print("\033[33m");
                        System.out.println("★★★★★:");
                    }
                    break;
                }
                case 2: {
                    AllGetOperator = (ArrayList<String>) FourStarOperator.clone();
                    if (AllGetOperator.size() != 0){
                        System.out.print("\033[35m");
                        System.out.println("★★★★:");
                    }
                    break;
                }
                case 3: {
                    AllGetOperator = (ArrayList<String>) ThreeStarOperator.clone();
                    if (AllGetOperator.size() != 0){
                        System.out.print("\033[37m");
                        System.out.println("★★★:");
                    }
                    break;
                }
            }
            Collections.sort(AllGetOperator);

            for (int j = 0; j < AllGetOperator.size(); j++) {
                System.out.print(AllGetOperator.get(j));
                if (j % 5 == 4 || j == AllGetOperator.size() - 1) System.out.println();
                else System.out.print(" ");
            }
        }
    }

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        System.out.print("\033[37m");
        System.out.println("抽卡模拟器");
        System.out.println("卡池:进攻、防守、战术交汇");
        System.out.println("本期UP:");
        System.out.println("六星:灰烬 占六星50%");
        System.out.println("五星:霜华/闪击 占五星50%");
        System.out.println("★★★★★★:2%");
        System.out.println("★★★★★:8%");
        System.out.println("★★★★:50%");
        System.out.println("★★★:40%");
        int n = 0, m = 0;//未抽到六星干员次数
        while (true){
            if (!FirstFiveYes) System.out.println(FirstFive + "次内寻访必得5★以上干员");
            System.out.println("1.寻访一次");
            System.out.println("2.寻访十次");
            System.out.println("3.查看未出六星次数");
            System.out.println("4.查看已招募干员");
            System.out.println("5.清除寻访记录");
            System.out.println("0.退出");
            int i = in.nextInt();
            switch (i) {
                case 1: {
                    m = Headhunt(m);
                    n += 1;
                    break;
                }

                case 2: {
                    for (int j = 0; j < 10; j++) m = Headhunt(m);
                    n += 10;
                    break;
                }

                case 3:{
                    System.out.println("当前已有 " + m + " 次未出六星");
                    break;
                }

                case 4: {
                    History();
                    break;
                }

                case 5: {
                    m = 0;
                    n = 0;
                    FirstFive = 10;
                    FirstFiveYes = false;
                    FirstAsh = 120;
                    FirstAshYes = false;
                    FirstOtherFiveYes = false;
                    SixStarOperator.clear();
                    FiveStarOperator.clear();
                    FourStarOperator.clear();
                    ThreeStarOperator.clear();
                    break;
                }

                case 0: {
                    System.exit(0);
                }
            }
            System.out.print("\033[37m");
            System.out.println("已招募 " + n + " 次");
            if (m < 50) System.out.println("当前六星招募概率: 2%");
            else System.out.println("当前六星招募概率: " + ((m-50)*2+4) + "%");
        }
    }
}